<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="../../../common/common-jstl.jspf" %>
<%@ include file="../../../common/common-js.jspf" %>
<!DOCTYPE html>
<html>
<head>
    <base href="${pageContext.request.contextPath }/"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <style type="text/css">
        .container {
            width: 100%;
            height: 300px;
        }

        .title {
            width: 100%;
            height: 12%;
            background-color: #5E5E5E;
        }

        .title > span {
            color: white;
            font-size: 16px;
            font-family: "黑体";
            line-height: 32px;
            text-indent: 1em;
            display: block;
        }

        .content {
            width: 100%;
            height: 88%;
            background-color: #F5F5F5;
        }

        .content table {
            border-collapse: collapse;
            width: 100%;
        }

        .content table td, .content table th {
            border: 1px solid #ccc;
            padding: 10px;
            text-align: center;
        }

    </style>
</head>
<body>
<div class="container">
    <div class="title"><span>角色信息列表</span></div>
    <div class="content">
        <table>
            <tr>
                <th>角色编号</th>
                <th>角色名称</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${roleList }" var="role">
                <tr>
                    <td>${role.roleId }</td>
                    <td>${role.roleName }</td>
                    <td>
                        <c:if test="${role.roleId!=1 }">
                            <a href="javascript:judgeDelete('${role.roleId }')">删除 </a>
                        </c:if>
                        |
                        <a href="javascript:updatePanel('${role.roleId }')">修改 </a>

                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
</div>
<script type="text/javascript">
    //删除的函数
    function judgeDelete(roleId) {
        var loginRightId = '${sessionScope.roleId}';
        if (loginRightId != roleId) {
            var url = "roleInfoController";
            $.get(url, {flag: "delete", roleId: roleId}, function (data) {
                if (data == "ok") {
                    layer.msg("删除成功", {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        layer.open({
                            type: 2,
                            title: false,
                            shadeClose: false,
                            shade: 0.5,
                            skin: 'layui-layer-rim',
                            /* closeBtn:false, */
                            area: ['1100px', '400px'],
                            content: "roleInfoController?flag=query"
                        });
                    });
                } else {
                    layer.msg("删除失败");
                }
            });
        } else {
            layer.msg("自己不能删自己");
        }

    }
    //修改的函数
    function updatePanel(roleId) {
        layer.open({
            type: 2,
            title: false,
            shadeClose: false,
            shade: 0.5,
            skin: 'layui-layer-rim',
            area: ['1100px', '400px'],
            content: "roleInfoController?flag=initUpdate&roleId=" + roleId
        })
    }
    /* 		//授权的函数
     function grant(userId) {
     layer.open({
     type: 2,
     title: false,
     shadeClose: false,
     shade: 0.5,
     skin: 'layui-layer-rim',
     area: ['1100px', '400px'],
     content: "rightInfoController?flag=query&roleId="+userId
     })
     } */
    /* 		function judgeDelete(userId) {
     var url = "userInfoController";
     $.get(url,{flag:"delete",userId:userId},function(data) {
     if (data=="yes") {
     layer.msg("删除成功",{
     icon: 1,
     time: 2000 //2秒关闭（如果不配置，默认是3秒）
     },function() {
     location.href="userInfoController?flag=list";
     });
     } else {
     layer.msg("删除失败");
     }
     });

     }

     function updatePanel(userId) {
     layer.open({
     type: 2,
     title: false,
     shadeClose: false,
     shade: 0.5,
     skin: 'layui-layer-rim',
     closeBtn:false,
     area: ['400px', '172px'],
     content: "userInfoController?flag=initUpdate&userId="+userId
     });
     }  */
</script>
</body>
</html>